home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / IPLDOC.ICN < prev    next >
Text File  |  1992-11-27  |  3KB  |  105 lines

  1. ############################################################################
  2. #
  3. #    File:     ipldoc.icn
  4. #
  5. #    Subject:  Program to collect library documentation
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     November 27, 1992
  10. #
  11. ###########################################################################
  12. #
  13. #  This program collects selected information from documentation headers
  14. #  for Icon procedure files.
  15. #
  16. #  If called with no arguments, it processes the files named in standard
  17. #  input.  E.g., in UNIX this might be:
  18. #
  19. #    ls *.icn | ipldoc
  20. #
  21. #  If called with an argument, that argument is taken to be a directory
  22. #  name and all files named *.icn in that directory are processed.
  23. #
  24. ############################################################################
  25. #
  26. #  Requires:  UNIX if called with an argument.
  27. #
  28. ############################################################################
  29.  
  30. procedure main(args)
  31.    local procedures, bar1, bar2, file, program, line, dir, input, max
  32.  
  33.    procedures := table()
  34.  
  35.    bar1 := repl("=", 75)
  36.    bar2 := repl("-", 75)
  37.  
  38.    if dir := \args[1] then
  39.       input := open("ls " || dir || "/*.icn" , "p")
  40.    else input := &input
  41.  
  42.    while file := read(input) do {
  43.  
  44.       program := open(file) | stop("*** cannot open program ", image(file))
  45.  
  46.       write(bar1, "\n")
  47.  
  48.       while line := read(program) | break do
  49.          line ? {
  50.             if tab(find("File:") + 6) then {
  51.                tab(many(' \t'))
  52.                write(file ,":")
  53.                write()
  54.                write(tab(0))
  55.                break
  56.                }
  57.             }
  58.       while line := read(program) | break do
  59.          line ? {
  60.             if ="##########" then break
  61.             }
  62.       while line := read(program) | break do
  63.          line ? {
  64.             if ="#" then {
  65.                if ="##########" then {
  66.                   line := read(program) | break
  67.                   line ? {
  68.                      if pos(0) then break
  69.                      else if ="#" then {
  70.                         write(bar2)
  71.                         write(" ", tab(0))
  72.                         }
  73.                      }
  74.                   }
  75.                else write(" ", tab(0))
  76.                }
  77.             else break
  78.             }
  79.       while line := read(program) | break do
  80.          line ? {
  81.             if ="procedure" then {
  82.                tab(many(' \t'))
  83.                if ="main(" then next
  84.                procedures[tab(upto(')') + 1)] := file
  85.                }
  86.             }
  87.       close(program)
  88.       }
  89.  
  90.    write(bar1)
  91.    write()
  92.    write("Procedure List")
  93.    write()
  94.  
  95.    max := 0
  96.  
  97.    every max <:= *!procedures | 45
  98.    max +:= 2
  99.  
  100.    procedures := sort(procedures, 3)
  101.  
  102.    while write(left(get(procedures), max), get(procedures))
  103.  
  104. end
  105.